const mysql = require('../db/mysql57');

const loginDao = {
    // 登录接口
    cardkeyLogin(cardkey) {
        let sql = `select
                id, userTypeId, url,
                DATE_FORMAT(endAt, '%Y-%m-%d %H:%i:%s') as endAt
            from User
            where card = ? and
                isDel = ? and
                isEnable = ? and
                count != maxCount
            LIMIT 1`;
        let data = [ cardkey, 'false', 'true' ];
        return mysql.sqlExec(sql, data);
    },
    // 次数加一的方法
    userLoginInc(id) {
        let sql = `update User set count = count + 1 where id = ?`;
        let data = id;
        return mysql.sqlExec(sql, data);
    },
};

module.exports = loginDao;
